import React from 'react';
import DataTable from 'components/DataTable';
import Icon from 'components/Icon';
import Button from 'components/Button';
import Upload from "components/Upload";
import Editor from 'components/Editor';
export const createColumns = (self, showArticleListModeTable) => [
    {
        title: '标题',
        name: 'title',
        tableItem: {},
        searchItem: {
            group: 'abc'
        },
        formItem: {
            rules: [
                {
                    required: true,
                    message: '请输入标题'
                }
            ]
        },
    },
    {
        title: '备注',
        name: 'notes',
        tableItem: {},
        formItem: {
            rules: [
                {
                    required: true,
                    message: '请输入备注'
                }
            ]
        },
    },
    {
        title: '背景颜色',
        name: 'bg_color',
        tableItem: {},
        formItem: { rules: [
            {
                required: true,
                message: '请输入背景颜色'
            }
        ]},
    },
    {
        title: '图标',
        name: 'icon',
        tableItem: {},
        formItem: {rules: [
            {
                required: true,
                message: '请输入图标'
            }
        ]},
    },
    {
        title: '内容',
        name: 'describe',
        formItem: {
            type: 'custom',
            render: (record, form) => {
                const { getFieldDecorator } = form;
                return (
                    <div>
                        {getFieldDecorator('describe', {
                            initialValue: record && record.describe
                        })(<Editor />)}
                    </div>
                )
            }
        },
    },
    {
        title: '缩略图',
        name: 'thumbnail_arr',
        formItem: {
            type: 'upload',
            listType: 'picture',
            action: '/system/upload/?savePath=adorn_process', // 后台接口 例：/uploadFile 会走代理
            fileName: 'file', // 后台接收的名字
            rules: [
                {
                    required: true,
                    message: '请选择图片'
                }
            ],
            maxFileSize: 1000, // 最大限制 kb
            max: 1
        }
    },
    {
        title: '操作',
        tableItem: {
            width: 120,
            fixed: 'right',
            render: (text, record) => (
                <DataTable.Oper>
                    <Button tooltip="修改" onClick={e => self.onUpdate(record)}>
                        <Icon type="edit" />
                    </Button>
                    <Button tooltip="关联" onClick={e => showArticleListModeTable(record, self)}>
                        <Icon type="equalizer" />
                    </Button>
                    <Button tooltip="删除" onClick={e => self.onDelete(record)}>
                        <Icon type="trash" />
                    </Button>
                </DataTable.Oper>
            )
        }
    }
];

export const ArticleTableColumns=(self)=>[
    {
        title: '标题',
        name: 'title',
        tableItem: {},
        searchItem: {},
    },
]
